<!DOCTYPE html><html lang="zh-CN" data-theme="light"><head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"><title>使用dbt5进行TPC-E测试 | emplay</title><meta name="keywords" content="TPC-E,性能测试"><meta name="author" content="emplay"><meta name="copyright" content="emplay"><meta name="format-detection" content="telephone=no"><meta name="theme-color" content="#ffffff"><meta name="description" content="PostgreSQL下使用dbt5进行TPC-E测试">
<meta property="og:type" content="article">
<meta property="og:title" content="使用dbt5进行TPC-E测试">
<meta property="og:url" content="https://blog.emplay.top/2022/07/20/%E4%BD%BF%E7%94%A8dbt5%E8%BF%9B%E8%A1%8CTPC-E%E6%B5%8B%E8%AF%95/index.html">
<meta property="og:site_name" content="emplay">
<meta property="og:description" content="PostgreSQL下使用dbt5进行TPC-E测试">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="">
<meta property="article:published_time" content="2022-07-20T00:00:00.000Z">
<meta property="article:modified_time" content="2022-08-19T00:30:02.204Z">
<meta property="article:author" content="emplay">
<meta property="article:tag" content="操作系统、数据库、办公软件、光影传奇、读史明智、志怪奇闻、三人成虎、琢玉成器、天高地阔，欲往观之....">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content=""><link rel="shortcut icon" href="/img/dbf.png"><link rel="canonical" href="https://blog.emplay.top/2022/07/20/%E4%BD%BF%E7%94%A8dbt5%E8%BF%9B%E8%A1%8CTPC-E%E6%B5%8B%E8%AF%95/"><link rel="preconnect" href="//cdn.jsdelivr.net"/><link rel="preconnect" href="//fonts.googleapis.com" crossorigin=""/><link rel="preconnect" href="//busuanzi.ibruce.info"/><link rel="stylesheet" href="/css/index.css"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free/css/all.min.css" media="print" onload="this.media='all'"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fancyapps/ui/dist/fancybox.min.css" media="print" onload="this.media='all'"><link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Titillium+Web&amp;display=swap" media="print" onload="this.media='all'"><script>const GLOBAL_CONFIG = { 
  root: '/',
  algolia: undefined,
  localSearch: {"path":"/search.xml","preload":true,"languages":{"hits_empty":"找不到您查询的内容：${query}"}},
  translate: undefined,
  noticeOutdate: undefined,
  highlight: {"plugin":"highlighjs","highlightCopy":true,"highlightLang":true,"highlightHeightLimit":false},
  copy: {
    success: '复制成功',
    error: '复制错误',
    noSupport: '浏览器不支持'
  },
  relativeDate: {
    homepage: false,
    post: false
  },
  runtime: '',
  date_suffix: {
    just: '刚刚',
    min: '分钟前',
    hour: '小时前',
    day: '天前',
    month: '个月前'
  },
  copyright: undefined,
  lightbox: 'fancybox',
  Snackbar: undefined,
  source: {
    justifiedGallery: {
      js: 'https://cdn.jsdelivr.net/npm/flickr-justified-gallery/dist/fjGallery.min.js',
      css: 'https://cdn.jsdelivr.net/npm/flickr-justified-gallery/dist/fjGallery.min.css'
    }
  },
  isPhotoFigcaption: true,
  islazyload: false,
  isAnchor: false
}</script><script id="config-diff">var GLOBAL_CONFIG_SITE = {
  title: '使用dbt5进行TPC-E测试',
  isPost: true,
  isHome: false,
  isHighlightShrink: false,
  isToc: true,
  postUpdate: '2022-08-19 00:30:02'
}</script><noscript><style type="text/css">
  #nav {
    opacity: 1
  }
  .justified-gallery img {
    opacity: 1
  }

  #recent-posts time,
  #post-meta time {
    display: inline !important
  }
</style></noscript><script>(win=>{
    win.saveToLocal = {
      set: function setWithExpiry(key, value, ttl) {
        if (ttl === 0) return
        const now = new Date()
        const expiryDay = ttl * 86400000
        const item = {
          value: value,
          expiry: now.getTime() + expiryDay,
        }
        localStorage.setItem(key, JSON.stringify(item))
      },

      get: function getWithExpiry(key) {
        const itemStr = localStorage.getItem(key)

        if (!itemStr) {
          return undefined
        }
        const item = JSON.parse(itemStr)
        const now = new Date()

        if (now.getTime() > item.expiry) {
          localStorage.removeItem(key)
          return undefined
        }
        return item.value
      }
    }
  
    win.getScript = url => new Promise((resolve, reject) => {
      const script = document.createElement('script')
      script.src = url
      script.async = true
      script.onerror = reject
      script.onload = script.onreadystatechange = function() {
        const loadState = this.readyState
        if (loadState && loadState !== 'loaded' && loadState !== 'complete') return
        script.onload = script.onreadystatechange = null
        resolve()
      }
      document.head.appendChild(script)
    })
  
      win.activateDarkMode = function () {
        document.documentElement.setAttribute('data-theme', 'dark')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#0d0d0d')
        }
      }
      win.activateLightMode = function () {
        document.documentElement.setAttribute('data-theme', 'light')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#ffffff')
        }
      }
      const t = saveToLocal.get('theme')
    
          if (t === 'dark') activateDarkMode()
          else if (t === 'light') activateLightMode()
        
      const asideStatus = saveToLocal.get('aside-status')
      if (asideStatus !== undefined) {
        if (asideStatus === 'hide') {
          document.documentElement.classList.add('hide-aside')
        } else {
          document.documentElement.classList.remove('hide-aside')
        }
      }
    
    const detectApple = () => {
      if(/iPad|iPhone|iPod|Macintosh/.test(navigator.userAgent)){
        document.documentElement.classList.add('apple')
      }
    }
    detectApple()
    })(window)</script><link rel="stylesheet" href="/css/iconfont/iconfont.css"><meta name="generator" content="Hexo 6.2.0"><link rel="alternate" href="/atom.xml" title="emplay" type="application/atom+xml">
</head><body><div id="loading-box"><div class="loading-left-bg"></div><div class="loading-right-bg"></div><div class="spinner-box"><div class="configure-border-1"><div class="configure-core"></div></div><div class="configure-border-2"><div class="configure-core"></div></div><div class="loading-word">加载中...</div></div></div><div id="web_bg"></div><div id="sidebar"><div id="menu-mask"></div><div id="sidebar-menus"><div class="avatar-img is-center"><img src="/img/emplay.png" onerror="onerror=null;src='/img/friend_404.gif'" alt="avatar"/></div><div class="sidebar-site-data site-data is-center"><a href="/archives/"><div class="headline">文章</div><div class="length-num">2</div></a><a href="/tags/"><div class="headline">标签</div><div class="length-num">1</div></a><a href="/categories/"><div class="headline">分类</div><div class="length-num">2</div></a></div><hr/><div class="menus_items"><div class="menus_item"><a class="site-page" href="/"><i class="fa-fw iconfont icon-zhuye"></i><span> 主页</span></a></div><div class="menus_item"><a class="site-page" href="/tags/"><i class="fa-fw iconfont icon-biaoqian"></i><span> 标签</span></a></div><div class="menus_item"><a class="site-page" href="/archives/"><i class="fa-fw iconfont icon-suoyouwenzhang"></i><span> 文章总览</span></a></div><div class="menus_item"><a class="site-page group" href="javascript:void(0);"><i class="fa-fw fas fa-list"></i><span> 学以广才</span><i class="fas fa-chevron-down"></i></a><ul class="menus_item_child"><li><a class="site-page child" href="/categories/%E7%90%A2%E7%8E%89%E6%88%90%E5%99%A8/"><i class="fa-fw iconfont icon-faxian_jiatingjiaoyu"></i><span> 琢玉成器</span></a></li><li><a class="site-page child" href="/categories/%E8%AF%BB%E5%8F%B2%E6%98%8E%E6%99%BA/"><i class="fa-fw iconfont icon-lishi"></i><span> 读史明智</span></a></li><li><a class="site-page child" href="/categories/%E6%89%8B%E5%B7%A5%E5%AE%9E%E9%AA%8C/"><i class="fa-fw iconfont icon-shiyan"></i><span> 手工实验</span></a></li><li><a class="site-page child" href="/categories/%E5%A4%A9%E9%AB%98%E5%9C%B0%E9%98%94/"><i class="fa-fw iconfont icon-lvyouxianlu"></i><span> 天高地阔</span></a></li><li><a class="site-page child" href="/categories/%E5%85%89%E5%BD%B1%E4%BC%A0%E5%A5%87/"><i class="fa-fw iconfont icon-sheying"></i><span> 光影传奇</span></a></li><li><a class="site-page child" href="/categories/%E8%AF%BB%E4%B9%A6%E7%AC%94%E8%AE%B0/"><i class="fa-fw iconfont icon-icon"></i><span> 读书笔记</span></a></li><li><a class="site-page child" href="/categories/%E5%90%83%E7%81%B0%E7%B3%BB%E5%88%97/"><i class="fa-fw iconfont icon-zaixianjiaocheng"></i><span> 吃灰系列</span></a></li></ul></div><div class="menus_item"><a class="site-page group" href="javascript:void(0);"><i class="fa-fw fas fa-list"></i><span> 计算机相关</span><i class="fas fa-chevron-down"></i></a><ul class="menus_item_child"><li><a class="site-page child" href="/categories/%E6%93%8D%E4%BD%9C%E7%B3%BB%E7%BB%9F/"><i class="fa-fw iconfont icon-qitacaozuoxitong"></i><span> 操作系统</span></a></li><li><a class="site-page child" href="/categories/%E6%95%B0%E6%8D%AE%E5%BA%93/"><i class="fa-fw iconfont icon-shujuku"></i><span> 数据库</span></a></li><li><a class="site-page child" href="/categories/%E7%AE%97%E6%B3%95%E9%80%BB%E8%BE%91/"><i class="fa-fw iconfont icon-suanfaguanligongju"></i><span> 算法逻辑</span></a></li><li><a class="site-page child" href="/categories/%E7%BC%96%E7%A8%8B%E8%AF%AD%E8%A8%80/"><i class="fa-fw iconfont icon-yuyan"></i><span> 编程语言</span></a></li><li><a class="site-page child" href="/categories/%E4%B8%8D%E6%83%B3%E4%BB%98%E9%92%B1/"><i class="fa-fw iconfont icon-pojiexiugai"></i><span> 不想付钱</span></a></li></ul></div><div class="menus_item"><a class="site-page group" href="javascript:void(0);"><i class="fa-fw fas fa-list"></i><span> 怡性养神</span><i class="fas fa-chevron-down"></i></a><ul class="menus_item_child"><li><a class="site-page child" href="/categories/%E7%94%B5%E5%BD%B1/"><i class="fa-fw iconfont icon-yingshi"></i><span> 电影</span></a></li><li><a class="site-page child" href="/categories/%E5%9B%BE%E5%BA%93/"><i class="fa-fw iconfont icon-24gf-photoAlbum"></i><span> 图库</span></a></li><li><a class="site-page child" href="/categories/%E9%9F%B3%E4%B9%90/"><i class="fa-fw iconfont icon-a-zujiantianchong_huaban1fuben17"></i><span> 音乐</span></a></li></ul></div><div class="menus_item"><a class="site-page" href="/link/"><i class="fa-fw fas fa-link"></i><span> 链接</span></a></div></div></div></div><div class="post" id="body-wrap"><header class="not-top-img" id="page-header"><nav id="nav"><span id="blog_name"><a id="site-name" href="/">emplay</a></span><div id="menus"><div id="search-button"><a class="site-page social-icon search"><i class="fas fa-search fa-fw"></i><span> 搜索</span></a></div><div class="menus_items"><div class="menus_item"><a class="site-page" href="/"><i class="fa-fw iconfont icon-zhuye"></i><span> 主页</span></a></div><div class="menus_item"><a class="site-page" href="/tags/"><i class="fa-fw iconfont icon-biaoqian"></i><span> 标签</span></a></div><div class="menus_item"><a class="site-page" href="/archives/"><i class="fa-fw iconfont icon-suoyouwenzhang"></i><span> 文章总览</span></a></div><div class="menus_item"><a class="site-page group" href="javascript:void(0);"><i class="fa-fw fas fa-list"></i><span> 学以广才</span><i class="fas fa-chevron-down"></i></a><ul class="menus_item_child"><li><a class="site-page child" href="/categories/%E7%90%A2%E7%8E%89%E6%88%90%E5%99%A8/"><i class="fa-fw iconfont icon-faxian_jiatingjiaoyu"></i><span> 琢玉成器</span></a></li><li><a class="site-page child" href="/categories/%E8%AF%BB%E5%8F%B2%E6%98%8E%E6%99%BA/"><i class="fa-fw iconfont icon-lishi"></i><span> 读史明智</span></a></li><li><a class="site-page child" href="/categories/%E6%89%8B%E5%B7%A5%E5%AE%9E%E9%AA%8C/"><i class="fa-fw iconfont icon-shiyan"></i><span> 手工实验</span></a></li><li><a class="site-page child" href="/categories/%E5%A4%A9%E9%AB%98%E5%9C%B0%E9%98%94/"><i class="fa-fw iconfont icon-lvyouxianlu"></i><span> 天高地阔</span></a></li><li><a class="site-page child" href="/categories/%E5%85%89%E5%BD%B1%E4%BC%A0%E5%A5%87/"><i class="fa-fw iconfont icon-sheying"></i><span> 光影传奇</span></a></li><li><a class="site-page child" href="/categories/%E8%AF%BB%E4%B9%A6%E7%AC%94%E8%AE%B0/"><i class="fa-fw iconfont icon-icon"></i><span> 读书笔记</span></a></li><li><a class="site-page child" href="/categories/%E5%90%83%E7%81%B0%E7%B3%BB%E5%88%97/"><i class="fa-fw iconfont icon-zaixianjiaocheng"></i><span> 吃灰系列</span></a></li></ul></div><div class="menus_item"><a class="site-page group" href="javascript:void(0);"><i class="fa-fw fas fa-list"></i><span> 计算机相关</span><i class="fas fa-chevron-down"></i></a><ul class="menus_item_child"><li><a class="site-page child" href="/categories/%E6%93%8D%E4%BD%9C%E7%B3%BB%E7%BB%9F/"><i class="fa-fw iconfont icon-qitacaozuoxitong"></i><span> 操作系统</span></a></li><li><a class="site-page child" href="/categories/%E6%95%B0%E6%8D%AE%E5%BA%93/"><i class="fa-fw iconfont icon-shujuku"></i><span> 数据库</span></a></li><li><a class="site-page child" href="/categories/%E7%AE%97%E6%B3%95%E9%80%BB%E8%BE%91/"><i class="fa-fw iconfont icon-suanfaguanligongju"></i><span> 算法逻辑</span></a></li><li><a class="site-page child" href="/categories/%E7%BC%96%E7%A8%8B%E8%AF%AD%E8%A8%80/"><i class="fa-fw iconfont icon-yuyan"></i><span> 编程语言</span></a></li><li><a class="site-page child" href="/categories/%E4%B8%8D%E6%83%B3%E4%BB%98%E9%92%B1/"><i class="fa-fw iconfont icon-pojiexiugai"></i><span> 不想付钱</span></a></li></ul></div><div class="menus_item"><a class="site-page group" href="javascript:void(0);"><i class="fa-fw fas fa-list"></i><span> 怡性养神</span><i class="fas fa-chevron-down"></i></a><ul class="menus_item_child"><li><a class="site-page child" href="/categories/%E7%94%B5%E5%BD%B1/"><i class="fa-fw iconfont icon-yingshi"></i><span> 电影</span></a></li><li><a class="site-page child" href="/categories/%E5%9B%BE%E5%BA%93/"><i class="fa-fw iconfont icon-24gf-photoAlbum"></i><span> 图库</span></a></li><li><a class="site-page child" href="/categories/%E9%9F%B3%E4%B9%90/"><i class="fa-fw iconfont icon-a-zujiantianchong_huaban1fuben17"></i><span> 音乐</span></a></li></ul></div><div class="menus_item"><a class="site-page" href="/link/"><i class="fa-fw fas fa-link"></i><span> 链接</span></a></div></div><div id="toggle-menu"><a class="site-page"><i class="fas fa-bars fa-fw"></i></a></div></div></nav></header><main class="layout" id="content-inner"><div id="post"><div id="post-info"><h1 class="post-title">使用dbt5进行TPC-E测试</h1><div id="post-meta"><div class="meta-firstline"><span class="post-meta-date"><i class="far fa-calendar-alt fa-fw post-meta-icon"></i><span class="post-meta-label">发表于</span><time class="post-meta-date-created" datetime="2022-07-20T00:00:00.000Z" title="发表于 2022-07-20 00:00:00">2022-07-20</time><span class="post-meta-separator">|</span><i class="fas fa-history fa-fw post-meta-icon"></i><span class="post-meta-label">更新于</span><time class="post-meta-date-updated" datetime="2022-08-19T00:30:02.204Z" title="更新于 2022-08-19 00:30:02">2022-08-19</time></span><span class="post-meta-categories"><span class="post-meta-separator">|</span><i class="fas fa-inbox fa-fw post-meta-icon"></i><a class="post-meta-categories" href="/categories/%E6%95%B0%E6%8D%AE%E5%BA%93/">数据库</a></span></div><div class="meta-secondline"><span class="post-meta-separator">|</span><span class="post-meta-pv-cv" id="" data-flag-title="使用dbt5进行TPC-E测试"><i class="far fa-eye fa-fw post-meta-icon"></i><span class="post-meta-label">阅读量:</span><span id="busuanzi_value_page_pv"><i class="fa-solid fa-spinner fa-spin"></i></span></span></div></div></div><article class="post-content" id="article-container"><h1 id="使用dbt5进行TPC-E测试"><a href="#使用dbt5进行TPC-E测试" class="headerlink" title="使用dbt5进行TPC-E测试"></a>使用dbt5进行TPC-E测试</h1><p>使用工具：dbt5、hgdb4.5.7</p>
<p>dbt5下载路径：<a target="_blank" rel="noopener" href="https://github.com/osdldbt/dbt5">https://github.com/osdldbt/dbt5</a></p>
<p>hgdb4.5.7自行安装</p>
<h2 id="编译安装R语言"><a href="#编译安装R语言" class="headerlink" title="编译安装R语言"></a>编译安装R语言</h2><p>dbt5生成测试报告时需要用到Python及R语言，一般操作系统默认安装Python2.7版本，可以直接使用该版本，生成测试报告时，需要使用Python调用R语言的功能，不要使用最新的R语言版本。此处选择的是与Python2.7及dbt5差多时间的R语言版本</p>
<p>R语言下载路径：<a target="_blank" rel="noopener" href="https://mirrors.tuna.tsinghua.edu.cn/CRAN/src/base/R-3/R-3.0.1.tar.gz">https://mirrors.tuna.tsinghua.edu.cn/CRAN/src/base/R-3/R-3.0.1.tar.gz</a></p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">#R语言编译安装过程比较比较简单，没啥可说的</span></span><br><span class="line">tar -zxf R-3.0.1.tar.gz</span><br><span class="line"><span class="built_in">cd</span> R-3.0.1</span><br><span class="line">./configure --prefix=/usr/local/R3 --with-gnu-ld --with-cairo  --with-x --enable-R-shlib</span><br><span class="line">make &amp;&amp; make install</span><br><span class="line"><span class="comment">#R语言的</span></span><br><span class="line"><span class="built_in">ln</span> -s /usr/local/R3/lib64/R/etc/ /usr/local/R3/etc</span><br><span class="line"><span class="built_in">ln</span> -s /usr/local/R3/lib64/R/lib /usr/local/R3/lib</span><br></pre></td></tr></table></figure>
<h2 id="编译安装Python插件rpy2"><a href="#编译安装Python插件rpy2" class="headerlink" title="编译安装Python插件rpy2"></a>编译安装Python插件rpy2</h2><p>Python缺少时间序列分析的包，做分析很不方便，R语言有很多分析用的包，可以在使用Python时，将R语言作为一个附属部分使用。简单说就是使用rpy2可以直接用Python调用R的功能。</p>
<p>因为用的Python2.7，rpy2也需要选择早期版本，这里使用的是与R3.0.1同一时期的版本2.4.0</p>
<p>下载路径：<a target="_blank" rel="noopener" href="https://github.com/rpy2/rpy2/releases/tag/RELEASE_2_4_0">https://github.com/rpy2/rpy2/releases/tag/RELEASE_2_4_0</a></p>
<p>编译安装过程</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">#RELEASE_2_4_0.tar.gz下载下来就叫这名字</span></span><br><span class="line">tar -zxf RELEASE_2_4_0.tar.gz</span><br><span class="line"><span class="built_in">cd</span> rpy2-RELEASE_2_4_0</span><br><span class="line"><span class="comment">#此处不用参考网上教程，注释extern void Rf_PrintWarnings(void)等内容，那是rpy2 2.3及之前版本的问题，2.4版本已经修复，直接安装即可。</span></span><br><span class="line">python setup.py build --r-home /usr/local/R3/lib64/R/ install</span><br></pre></td></tr></table></figure>
<h2 id="编译安装dbt5"><a href="#编译安装dbt5" class="headerlink" title="编译安装dbt5"></a>编译安装dbt5</h2><h3 id="编译安装"><a href="#编译安装" class="headerlink" title="编译安装"></a>编译安装</h3><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">#加载数据库环境变量</span></span><br><span class="line"><span class="built_in">source</span> ~/.bashrc</span><br><span class="line"><span class="comment">#dbt5使用的cmake，需要事先安装</span></span><br><span class="line">yum install cmake</span><br><span class="line"><span class="comment">#下载dbt5源码</span></span><br><span class="line">git <span class="built_in">clone</span> https://github.com/osdldbt/dbt5 dbt5</span><br><span class="line"><span class="comment">#切换到dbt5目录</span></span><br><span class="line"><span class="built_in">cd</span> dbt5</span><br><span class="line"><span class="comment">#编译</span></span><br><span class="line">cmake CMakeLists.txt -DDBMS=pgsql</span><br><span class="line"><span class="comment">#安装dbt5，DESTDIR后指定安装路径：/opt/dbt-5，此处可能会报错，报错解决方法见下面注意部分</span></span><br><span class="line">make install DESTDIR=/opt/dbt-5</span><br><span class="line"><span class="comment">#编译EGen</span></span><br><span class="line"><span class="built_in">cd</span> dbt5/egen/prj</span><br><span class="line">make -f Makefile.pgsql</span><br><span class="line"><span class="comment">#编译安装存储过程到数据库安装目录</span></span><br><span class="line"><span class="built_in">cd</span> dbt5/storedproc/pgsql/c</span><br><span class="line">make install</span><br></pre></td></tr></table></figure>
<h3 id="报错处理"><a href="#报错处理" class="headerlink" title="报错处理"></a>报错处理</h3><p><em><strong>注意：如果make install时报如下错误</strong></em></p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line">[root@k8s4 dbt5]<span class="comment"># make install</span></span><br><span class="line">[  1%] Building CXX object CMakeFiles/bin/BrokerageHouseMain.<span class="built_in">dir</span>/src/interfaces/TxnHarnessSendToMarket.o</span><br><span class="line">In file included from src/include/TxnHarnessSendToMarket.h:17:0,</span><br><span class="line">                 from /opt/dbt5/src/interfaces/TxnHarnessSendToMarket.cpp:11:</span><br><span class="line">src/include/CSocket.h: In member <span class="keyword">function</span> ‘void CSocket::closeListenerSocket()’:</span><br><span class="line">src/include/CSocket.h:42:47: error: ‘close’ was not declared <span class="keyword">in</span> this scope</span><br><span class="line">  void <span class="function"><span class="title">closeListenerSocket</span></span>() &#123; close(m_listenfd); &#125;</span><br><span class="line">                                               ^</span><br><span class="line">make[2]: *** [CMakeFiles/bin/BrokerageHouseMain.<span class="built_in">dir</span>/src/interfaces/TxnHarnessSendToMarket.o] Error 1</span><br><span class="line">make[1]: *** [CMakeFiles/bin/BrokerageHouseMain.<span class="built_in">dir</span>/all] Error 2</span><br><span class="line">make: *** [all] Error 2</span><br></pre></td></tr></table></figure>
<p><em><strong>处理方式：修改文件dbt5&#x2F;src&#x2F;include&#x2F;CSocket.h，添加“#include &lt;unistd.h&gt;”</strong></em></p>
<figure class="highlight cpp"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line">vi src/include/CSocket.h</span><br><span class="line"><span class="meta">#<span class="keyword">include</span> <span class="string">&lt;netdb.h&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="keyword">include</span> <span class="string">&lt;sys/types.h&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="keyword">include</span> <span class="string">&lt;sys/socket.h&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="keyword">include</span> <span class="string">&lt;netinet/in.h&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="keyword">include</span> <span class="string">&lt;arpa/inet.h&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="keyword">include</span> <span class="string">&lt;errno.h&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="keyword">include</span> <span class="string">&quot;CThreadErr.h&quot;</span></span></span><br><span class="line"><span class="meta">#<span class="keyword">include</span> <span class="string">&quot;MiscConsts.h&quot;</span></span></span><br><span class="line"><span class="comment">/*添加如下内容*/</span></span><br><span class="line"><span class="meta">#<span class="keyword">include</span> <span class="string">&lt;unistd.h&gt;</span></span></span><br></pre></td></tr></table></figure>
<h3 id="功能说明"><a href="#功能说明" class="headerlink" title="功能说明"></a>功能说明</h3><p>编译完成后，可执行文件在dbt5下的bin目录中，列表即部分文件功能如下，主要用到是dbt5-pgsql-build-db、dbt5-run-workload</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br></pre></td><td class="code"><pre><span class="line">[root@k8s4 bin]<span class="comment"># pwd</span></span><br><span class="line">/opt/dbt-5/bin</span><br><span class="line">[root@k8s4 bin]<span class="comment"># ll</span></span><br><span class="line">total 10684</span><br><span class="line">-rwxr-xr-x 1 root root 1490512 Jun 14 16:13 BrokerageHouseMain      <span class="comment">#模拟券商</span></span><br><span class="line">-rwxr-xr-x 1 root root    9923 Jun  9 14:44 dbt5-generate-report</span><br><span class="line">-rwxr-xr-x 1 root root     416 Jun  9 14:44 dbt5-get-os-info</span><br><span class="line">-rwxr-xr-x 1 root root     612 Jun  9 14:44 dbt5-pgsql-backup-db</span><br><span class="line">-rwxr-xr-x 1 root root    3490 Jun  9 14:44 dbt5-pgsql-build-db    <span class="comment">#创建测试数据库，写入测试数据</span></span><br><span class="line">-rwxr-xr-x 1 root root    2717 Jun  9 14:44 dbt5-pgsql-check-db</span><br><span class="line">-rwxr-xr-x 1 root root    1374 Jun  9 14:44 dbt5-pgsql-create-db</span><br><span class="line">-rwxr-xr-x 1 root root   30291 Jun  9 14:44 dbt5-pgsql-create-indexes</span><br><span class="line">-rwxr-xr-x 1 root root   22206 Jun  9 14:44 dbt5-pgsql-create-tables</span><br><span class="line">-rwxr-xr-x 1 root root   22590 Jun  9 14:44 dbt5-pgsql-db-plans</span><br><span class="line">-rwxr-xr-x 1 root root    3824 Jun  9 14:44 dbt5-pgsql-db-stat</span><br><span class="line">-rwxr-xr-x 1 root root     521 Jun  9 14:44 dbt5-pgsql-drop-db</span><br><span class="line">-rwxr-xr-x 1 root root    2753 Jun  9 14:44 dbt5-pgsql-drop-tables</span><br><span class="line">-rwxr-xr-x 1 root root    1736 Jun  9 14:44 dbt5-pgsql-load-stored-procs</span><br><span class="line">-rwxr-xr-x 1 root root     618 Jun  9 14:44 dbt5-pgsql-restore-db</span><br><span class="line">-rwxr-xr-x 1 root root    1061 Jun  9 14:44 dbt5-pgsql-start-db</span><br><span class="line">-rwxr-xr-x 1 root root     470 Jun  9 14:44 dbt5-pgsql-stop-db</span><br><span class="line">-rwxr-xr-x 1 root root    4024 Jun  9 14:44 dbt5-plot-transaction-rate</span><br><span class="line">-rwxr-xr-x 1 root root    5094 Jun  9 14:44 dbt5-post-process       <span class="comment">#生成测试报告</span></span><br><span class="line">-rwxr-xr-x 1 root root   19029 Jun  9 14:44 dbt5-run-workload       <span class="comment">#运行测试</span></span><br><span class="line">-rwxr-xr-x 1 root root    2509 Jun  9 14:44 dbt5-sysstats</span><br><span class="line">-rwxr-xr-x 1 root root 3115456 Jun 14 16:14 DriverMain              <span class="comment">#模拟客户端</span></span><br><span class="line">-rwxr-xr-x 1 root root 1949824 Jun 14 16:15 MarketExchangeMain      <span class="comment">#模拟交易所</span></span><br><span class="line">-rwxr-xr-x 1 root root 4196000 Jun 14 16:17 TestTxn</span><br></pre></td></tr></table></figure>
<h2 id="开始测试"><a href="#开始测试" class="headerlink" title="开始测试"></a>开始测试</h2><h3 id="设置环境变量"><a href="#设置环境变量" class="headerlink" title="设置环境变量"></a>设置环境变量</h3><p>以下环境变量根据实际情况进行修改</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">#数据库环境变量内容如下，如果加载过就不用加载了，要注意写上PGUSER</span></span><br><span class="line"><span class="built_in">export</span> HG_BASE=/opt/pg14</span><br><span class="line"><span class="built_in">export</span> HGDB_HOME=/opt/pg14</span><br><span class="line"><span class="built_in">export</span> PGPORT=5432</span><br><span class="line"><span class="built_in">export</span> PGDATABASE=postgres</span><br><span class="line"><span class="built_in">export</span> PGDATA=<span class="variable">$HGDB_HOME</span>/data</span><br><span class="line"><span class="built_in">export</span> PATH=<span class="variable">$HGDB_HOME</span>/bin:<span class="variable">$PATH</span></span><br><span class="line"><span class="built_in">export</span> PGUSER=postgres</span><br><span class="line"><span class="comment">#dbt5环境变量</span></span><br><span class="line"><span class="built_in">export</span> EGENDIR=/opt/dbt5/egen</span><br><span class="line"><span class="built_in">export</span> DBT5DBNAME=dbt5</span><br><span class="line"><span class="built_in">export</span> DBT5PGDATA=/data/hgdb457</span><br><span class="line"><span class="built_in">export</span> DBT5TSDIR=/opt/dbt5</span><br><span class="line"><span class="built_in">export</span> DBT5_HOME=/opt/dbt5</span><br><span class="line"><span class="built_in">export</span> PATH=:<span class="variable">$DBT5_HOME</span>/bin:<span class="variable">$PATH</span></span><br><span class="line"><span class="comment">#R语言环境变量</span></span><br><span class="line"><span class="built_in">export</span> R_HOME=/usr/local/R3/lib64/R</span><br><span class="line"><span class="built_in">export</span> PATH=:<span class="variable">$R_HOME</span>/bin:<span class="variable">$PATH</span></span><br><span class="line"><span class="built_in">export</span> LD_LIBRARY_PATH=/usr/local/R3/lib64/R/lib:<span class="variable">$LD_LIBRARY_PATH</span></span><br><span class="line"><span class="comment">#把密码写到环境变量中，写到pgpass中，测试过程中要求输入密码</span></span><br><span class="line"><span class="built_in">export</span> PGPASSWORD=Qwert@1234</span><br></pre></td></tr></table></figure>
<h3 id="创建测试数据库"><a href="#创建测试数据库" class="headerlink" title="创建测试数据库"></a>创建测试数据库</h3><p>使用dbt5-pgsql-build-db命令创建测试数据库及生成测试数据</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">#dbt5-pgsql-build-db帮助信息</span></span><br><span class="line">[root@k8s4 bin]<span class="comment"># dbt5-pgsql-build-db -h</span></span><br><span class="line">Usage:</span><br><span class="line">    ./dbt5-pgsql-build-db [option]</span><br><span class="line">    ./dbt5-pgsql-build-db -h</span><br><span class="line">Options:</span><br><span class="line">    -b &lt;<span class="built_in">integer</span>&gt; </span><br><span class="line">        Beginning customer ordinal position</span><br><span class="line">        设置客户起始编号，默认从1开始</span><br><span class="line">    -c &lt;<span class="built_in">integer</span>&gt;</span><br><span class="line">        Number of customers <span class="keyword">for</span> this instance</span><br><span class="line">        生成的测试数据中有多少个客户账号，默认5000</span><br><span class="line">    -d &lt;dbname&gt;</span><br><span class="line">        PGDATABASE name</span><br><span class="line">        数据库名称</span><br><span class="line">    -h</span><br><span class="line">        this <span class="built_in">help</span></span><br><span class="line">    -i &lt;path&gt;</span><br><span class="line">        Path to EGen</span><br><span class="line">        EGen的路径，不指定使用环境变量中的设置</span><br><span class="line">    -l &lt;port&gt;</span><br><span class="line">        database port</span><br><span class="line">        数据库端口</span><br><span class="line">    -p &lt;database_parameters&gt;</span><br><span class="line">        PostgreSQL database parameters</span><br><span class="line">        指定数据库参数</span><br><span class="line">    -r</span><br><span class="line">        Drop existing database before building a new database</span><br><span class="line">        创建新库时，如果已经存在，则删掉已存在的数据库</span><br><span class="line">    -s &lt;scale fact (customers per 1 trtps)</span><br><span class="line">        比例因子，每个客户操作通过是1trtps，具体怎么调节还不明白，默认值500</span><br><span class="line">    -t &lt;<span class="built_in">integer</span>&gt;</span><br><span class="line">        Number of customers (total)</span><br><span class="line">        客户端数量</span><br><span class="line">    -u</span><br><span class="line">        Use tablespaces</span><br><span class="line">        表示使用表空间，好像没啥用</span><br><span class="line">    -w &lt;days&gt;</span><br><span class="line">        Initial trade days (business days) to populate</span><br><span class="line">        初始化多少天的交易数据，默认300天</span><br><span class="line"></span><br><span class="line"></span><br><span class="line"><span class="comment">#生成测试数据，环境变量设置好后，会自动初始化、创建数据库、写入测试数据，通过设置交易数据的天数，控制数据量，100天数据量约5G</span></span><br><span class="line">[root@k8s4 bin]<span class="comment"># dbt5-pgsql-build-db -l 5457 -c 1000 -t 1000 -w 100</span></span><br><span class="line">Creating database...</span><br><span class="line">=======================================</span><br><span class="line">PGData directory /data/hgdb457 already exists</span><br><span class="line">Skipping initdb</span><br><span class="line">=======================================</span><br><span class="line">Database is already started.</span><br><span class="line">....</span><br></pre></td></tr></table></figure>
<h3 id="运行测试"><a href="#运行测试" class="headerlink" title="运行测试"></a>运行测试</h3><p>使用命令dbt5-run-workload进行测试</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">#dbt5-run-workload帮助选项</span></span><br><span class="line">[root@k8s4 bin]<span class="comment"># dbt5-run-workload -h</span></span><br><span class="line">./dbt5-run-workload: option requires an argument -- h</span><br><span class="line"></span><br><span class="line">error: specify <span class="built_in">which</span> dbms system to <span class="built_in">test</span> using -a &lt;pgsql&gt;</span><br><span class="line"></span><br><span class="line">usage: run_workload.sh -c &lt;number of customers&gt; -d &lt;duration of <span class="built_in">test</span>&gt; -u &lt;number of <span class="built_in">users</span>&gt;</span><br><span class="line">必选项：-c 客户数，跟加载数据时一样；-d 运行时间，单位秒；-u 同时跑多少用户，相当于数据库上的会话数</span><br><span class="line">other options:</span><br><span class="line">       -a &lt;pgsql&gt;   指定数据库类型，这里只有一个选项pg</span><br><span class="line">       -b &lt;database parameters&gt;    设置数据库启动参数，忽略就好</span><br><span class="line">       -f &lt;scale <span class="built_in">factor</span>. (default 500)&gt;       比例因子</span><br><span class="line">       -h &lt;database host name. (default localhost)&gt;   数据库地址，一定要写，本机也要写localhost，不然不连数据库，原因未知</span><br><span class="line">       -i &lt;egen_path&gt;       egen的路径</span><br><span class="line">       -l &lt;pacing delay. (default 0)&gt;      延迟，可能是交易峰谷间的延迟，默认0</span><br><span class="line">       -n &lt;database name. (default dbt5)&gt;   数据库名称，不写默认dbt5</span><br><span class="line">       -o &lt;result output <span class="built_in">dir</span>&gt;               结果存放路径，会自动生成一个目录</span><br><span class="line">       -p &lt;database port number. (default 5432)&gt;     数据库端口</span><br><span class="line">       -q &lt;event1,[event2,...]&gt; (Linux perf events)     Linux性能事件，调用的是perf命令，感兴趣的自己研究吧</span><br><span class="line">       -r &lt;random number seed, invalidates <span class="built_in">test</span>&gt;        随机数种子，无效测试。没明白是做什么的，需要的可也翻一下源码</span><br><span class="line">       -s &lt;delay between starting threads <span class="keyword">in</span> milliseconds (default 1000)&gt;  启动线程间的延迟时间，默认1000ms</span><br><span class="line">       -t &lt;customers total&gt;          测试使用的客户数</span><br><span class="line">       -w &lt;initial trade days. (default 300)&gt;   初始交易天数，应该是小于等于生成数据时的天数</span><br><span class="line">       -x (oprofile)          是否使用oprofile进行性能分析，选择了还需要装oprofile，太麻烦了，没测试</span><br><span class="line">       -y (readprofile)       是否readprofile跟踪内核性能，同样需要安装，未测试</span><br><span class="line">       -z &lt;comment describing this <span class="built_in">test</span> run&gt;       给本次测试写个注释吧</span><br><span class="line"></span><br><span class="line"><span class="comment">#一个简单测试</span></span><br><span class="line">[root@k8s4 bin]<span class="comment"># dbt5-run-workload -a pgsql -c 1000 -t 1000 -d 120 -u 5 -f 1000 -w 100 -p 5457 -n dbt5 -h localhost -o ./results</span></span><br><span class="line">waiting <span class="keyword">for</span> server to start.... <span class="keyword">done</span></span><br><span class="line">server started</span><br><span class="line"></span><br><span class="line">************************************************************************</span><br><span class="line">*                  DBT-5 <span class="built_in">test</span> started                                  *</span><br><span class="line">*                                                                      *</span><br><span class="line">************************************************************************</span><br><span class="line">*                                                                      *</span><br><span class="line">*  Test consists of 4 stages:                                          *</span><br><span class="line">*                                                                      *</span><br><span class="line">*  1. Start of the Brokerage House server                              *</span><br><span class="line">*  2. Start of the Market Exchange server                              *</span><br><span class="line">*  3. Test (Start of the Customer Emulator)                            *</span><br><span class="line">*  4. Processing of results                                            *</span><br><span class="line">*                                                                      *</span><br><span class="line">************************************************************************</span><br><span class="line">Results can be found <span class="keyword">in</span>: ./results</span><br><span class="line"></span><br><span class="line">1. Starting Brokerage House server</span><br><span class="line">Sleeping 1 seconds</span><br><span class="line"></span><br><span class="line">2. Starting Market Exchange server</span><br><span class="line"></span><br><span class="line">3. Starting Customer driver: 5 user(s)</span><br><span class="line">   1 user starting every 1000 milliseconds...</span><br><span class="line">Results will be written to: ./results</span><br><span class="line">Sleeping 6 seconds</span><br><span class="line">Sleeping 120 seconds</span><br><span class="line"></span><br><span class="line">4. Run Post processing analyses</span><br><span class="line">Killing Servers...</span><br><span class="line">waiting <span class="keyword">for</span> server to shut down........ <span class="keyword">done</span></span><br><span class="line">server stopped</span><br><span class="line">&gt;&gt; Test completed.</span><br><span class="line">Results are <span class="keyword">in</span>: ./results</span><br><span class="line"></span><br><span class="line">                          Response Time</span><br><span class="line">                            (seconds)</span><br><span class="line">Transaction             % Average: 90th %   Total Rollbacks    % Warning Invalid</span><br><span class="line">----------------- ------- --------------- ------- -------------- ------- -------</span><br><span class="line">Trade Result        8.309     nan:  0.018    3355      0   0.00%       0       0</span><br><span class="line">Broker Volume       4.998     nan:  0.007    2018      0   0.00%       0       0</span><br><span class="line">Customer Position  13.282     nan:  0.025    5363      0   0.00%       0       0</span><br><span class="line">Market Feed         0.763     nan:  0.014     336     28   8.33%       0       0</span><br><span class="line">Market Watch        0.166     nan:  0.006    7439   7372  99.10%       0       0</span><br><span class="line">Security Detail     0.396     nan:  0.007    5777   5617  97.23%       0     160</span><br><span class="line">Trade Lookup        8.141     nan:  0.111    3287      0   0.00%       0       0</span><br><span class="line">Trade Order        10.211     nan:  0.015    4164     41   0.98%       0       0</span><br><span class="line">Trade Status       19.338     nan:  0.040    7808      0   0.00%       0       0</span><br><span class="line">Trade Update        2.051     nan:  0.141     828      0   0.00%       0       0</span><br><span class="line">Data Maintenance      N/A     nan:  0.011       2      0   0.00%       0       0</span><br><span class="line">----------------- ------- --------------- ------- -------------- ------- -------</span><br><span class="line">27.96 trade-result transactions per second (trtps)</span><br><span class="line">0.1 minute(s) to ramp up</span><br><span class="line">2.0 minute steady state duration</span><br><span class="line"></span><br></pre></td></tr></table></figure>
<p>结果查看，整体内容稍微有点复杂，可以只简单看倒数第三行，即：27.96 trade-result transactions per second (trtps)，这里表示性能指标(tpsE， transactions per second E)和性价比(美元&#x2F;tpsE)，分值越大，性能越好。其他根据字面意思理解就好。</p>
<h2 id="TPC-E及dbt5简单介绍"><a href="#TPC-E及dbt5简单介绍" class="headerlink" title="TPC-E及dbt5简单介绍"></a>TPC-E及dbt5简单介绍</h2><h3 id="什么是TPC-E"><a href="#什么是TPC-E" class="headerlink" title="什么是TPC-E"></a>什么是TPC-E</h3><p>TPC 测试基准 E (下文称 TPC-E) 是由事务处理性能委员会 (下称 TPC) 开发的一个新的用于测试 OLTP 负载的测试基准(基准于 2007 年被审核通过)。 TPC-E 通过模拟了证券交易公司的业务来测试数据库的 OLTP 性能。TPC-E 测试的重点是数据库，更多关注的是这个数据库处理来自证券公司和其客户账号的相关交易。 尽管在 TPC-E 测试基准之下的业务模型是一个证券公司的业务，但是数据库的表结构和数据分布，以及交易本身和实现规则都是尽最大程度的测试当下的 OLTP 数据库系统。</p>
<h3 id="与TPCC的区别"><a href="#与TPCC的区别" class="headerlink" title="与TPCC的区别"></a>与TPCC的区别</h3><p>关键的区别是，TPC-E 基准配置将更像一个真实客户会实际使用的配置。 这意味着基准测试中使用的软件和硬件配置应与客户端使用的软件相似或相同。 TPC-C 配置的绝对大小不能反映典型的客户端配置。 </p>
<p>TPC-C模拟了批发分销商，拥有少量库存库存充足的仓库，为大量零售点提供服务，在这个场景下，通过衡量每分钟交易数（TPMC）表示性能情况。这种场景严重依赖磁盘IO。</p>
<p>TPC-E模拟了证券交易场景，使用由波动的股票价格驱动增加场景复杂度，同事模拟客户下单、限价交易、止损等场景。TPC-E场景更符合最新的OLTP场景，对磁盘IO性能比TPC-C低。</p>
<p>TPC-H用于测试OLAP场景，此处不介绍了。</p>
<h3 id="什么是dbt5"><a href="#什么是dbt5" class="headerlink" title="什么是dbt5"></a>什么是dbt5</h3><p>简单来说dbt5就是TPC-E基准测试规范的一个实现。作为Google Summer of Code 2006中的一个项目，由Rilson Nascimento开发，由Mark Wong担任导师。</p>
<h2 id="dbt5架构"><a href="#dbt5架构" class="headerlink" title="dbt5架构"></a>dbt5架构</h2><p>业务架构</p>
<p><img src="/images/%E4%BD%BF%E7%94%A8dbt5%E8%BF%9B%E8%A1%8CTPC-E%E6%B5%8B%E8%AF%95_1.png" alt="image"></p>
<p>设计架构</p>
<p><img src="/images/%E4%BD%BF%E7%94%A8dbt5%E8%BF%9B%E8%A1%8CTPC-E%E6%B5%8B%E8%AF%95_2.png" alt="image"></p>
<h2 id="dbt5中的表"><a href="#dbt5中的表" class="headerlink" title="dbt5中的表"></a>dbt5中的表</h2><table>
<thead>
<tr>
<th>类别</th>
<th>表名</th>
<th>注释</th>
</tr>
</thead>
<tbody><tr>
<td>客户相关</td>
<td>ACCOUNT_PERMISSION</td>
<td>客户账目许可表</td>
</tr>
<tr>
<td></td>
<td>CUSTOMER</td>
<td>客户信息表</td>
</tr>
<tr>
<td></td>
<td>CUSTOMER_ACCOUNT</td>
<td>客户账目表</td>
</tr>
<tr>
<td></td>
<td>CUSTOMER_TAXRATE</td>
<td>客户税率表</td>
</tr>
<tr>
<td></td>
<td>HOLDING</td>
<td>客户股票持有表</td>
</tr>
<tr>
<td></td>
<td>HOLDING_HISTORY</td>
<td>客户股票持有历史表</td>
</tr>
<tr>
<td></td>
<td>HOLDING_SUMMARY</td>
<td>客户股票持有总表</td>
</tr>
<tr>
<td></td>
<td>WATCH_ITEM</td>
<td>客户观察证券列表</td>
</tr>
<tr>
<td>经纪人相关</td>
<td>BROKER</td>
<td>经纪人表</td>
</tr>
<tr>
<td></td>
<td>CASH_TRANSACTION</td>
<td>现金交易表</td>
</tr>
<tr>
<td></td>
<td>CHARGE</td>
<td>交易费用表</td>
</tr>
<tr>
<td></td>
<td>COMMISSION_RATE</td>
<td>佣金率表</td>
</tr>
<tr>
<td></td>
<td>SETTLEMENT</td>
<td>结算表</td>
</tr>
<tr>
<td></td>
<td>SETTLEMENT</td>
<td>结算表</td>
</tr>
<tr>
<td></td>
<td>TRADE_HISTORY</td>
<td>交易历史表</td>
</tr>
<tr>
<td></td>
<td>TRADE_REQUEST</td>
<td>交易请求表</td>
</tr>
<tr>
<td></td>
<td>TRADE_TYPE</td>
<td>交易类型表</td>
</tr>
<tr>
<td>交易所相关</td>
<td>COMPANY</td>
<td>公司表</td>
</tr>
<tr>
<td></td>
<td>COMPANY_COMPETITOR</td>
<td>公司竞争者表</td>
</tr>
<tr>
<td></td>
<td>DAILY_MARKET</td>
<td>日常市场统计表</td>
</tr>
<tr>
<td></td>
<td>EXCHANGE</td>
<td>交易所表</td>
</tr>
<tr>
<td></td>
<td>FINANCIAL</td>
<td>财政表</td>
</tr>
<tr>
<td></td>
<td>INDUSTRY</td>
<td>行业表</td>
</tr>
<tr>
<td></td>
<td>LAST_TRADE</td>
<td>最后交易表</td>
</tr>
<tr>
<td></td>
<td>NEWS_ITEM</td>
<td>新闻项表</td>
</tr>
<tr>
<td></td>
<td>NEWS_XREF</td>
<td>公司新闻参照表</td>
</tr>
<tr>
<td></td>
<td>SECTOR</td>
<td>公司领域表</td>
</tr>
<tr>
<td></td>
<td>SECURITY</td>
<td>证券表</td>
</tr>
<tr>
<td>其他类别</td>
<td>ADDRESS</td>
<td>地址表</td>
</tr>
<tr>
<td></td>
<td>STATUS_TYPE</td>
<td>交易状态表</td>
</tr>
<tr>
<td></td>
<td>TAXRATE</td>
<td>税率表</td>
</tr>
<tr>
<td></td>
<td>ZIP_CODE</td>
<td>邮政编码表</td>
</tr>
</tbody></table>
<p>TPC-E标准中定义的事务有12种，每个事务对应数据库管理系统中的一个或多个带输入和输出参数的存储过程，单个存储过程叫做一个事务帧。事务的种类有如下几种：</p>
<ol>
<li>Broker-Volume：经纪人交易统计事务，包含1个事务帧；</li>
<li>Customer-Position：客户价值统计事务，包含3个事务帧；</li>
<li>Market-Watch：市场观察事务，包含1个事务帧；</li>
<li>Security-Detail：证券信息事务，包含1个事务帧；</li>
<li>Trade-Lookup：交易查询事务，包含4个事务帧；</li>
<li>Trade-Order：交易执行事务，包含6个事务帧；</li>
<li>Trade-Status：交易状态事务，包含1个事务帧；</li>
<li>Trade-Update：交易修正事务，包含3个事务帧；</li>
<li>Market-Feed：市场跟踪事务，包含1个事务帧，该事务由TradeOrder事务引起；</li>
<li>Trade-Result：交易结果更新事务，包含6个事务帧，该事务由TradeOrder事务引起；</li>
<li>Data-Maintenance：数据维护事务，包含1个事务帧，每60秒执行一次；</li>
<li>Trade-Cleanup：交易清理事务，包含1个事务帧，测试开始时执行一次，不强制使用。</li>
</ol>
<p>前8种事务由证券公司执行，第9-10号事务由交易所执行，最后两种事务属于数据库维护事务，与客户操作无关。</p>
<h3 id="dbt5的优缺点"><a href="#dbt5的优缺点" class="headerlink" title="dbt5的优缺点"></a>dbt5的优缺点</h3><p>优点：</p>
<p>1、主程序使用C++编写，速度较快</p>
<p>2、提供了完整的测试数据</p>
<p>3、场景比benchmarkSQL更复杂，更贴近现实使用的业务系统</p>
<p>4、监控手段多样，信息详细，可以直接生产漂亮的报告格式</p>
<p>5、使用Libpq连接数据库，理论速度更快</p>
<p>6、GitHub上已经有了支持docker的更新，可以打包成docker镜像</p>
<p>7、复杂的场景可以用来作为pg优化的练手程序</p>
<p>缺点：</p>
<p>1、安装配置较复杂，使用的语言包括shell、Python、R、C++</p>
<p>2、没有服务端程序没有使用连接池，不能对数据库进行极限压测。如果要想跑出高分，修改程序增加连接池效果会好很多</p>
<p>3、有一定的学习成本</p>
</article><div class="post-copyright"><div class="post-copyright__author"><span class="post-copyright-meta">文章作者: </span><span class="post-copyright-info"><a href="https://blog.emplay.top">emplay</a></span></div><div class="post-copyright__type"><span class="post-copyright-meta">文章链接: </span><span class="post-copyright-info"><a href="https://blog.emplay.top/2022/07/20/%E4%BD%BF%E7%94%A8dbt5%E8%BF%9B%E8%A1%8CTPC-E%E6%B5%8B%E8%AF%95/">https://blog.emplay.top/2022/07/20/%E4%BD%BF%E7%94%A8dbt5%E8%BF%9B%E8%A1%8CTPC-E%E6%B5%8B%E8%AF%95/</a></span></div><div class="post-copyright__notice"><span class="post-copyright-meta">版权声明: </span><span class="post-copyright-info">本博客所有文章除特别声明外，均采用 <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/" target="_blank">CC BY-NC-SA 4.0</a> 许可协议。转载请注明来自 <a href="https://blog.emplay.top" target="_blank">emplay</a>！</span></div></div><div class="tag_share"><div class="post-meta__tag-list"></div><div class="post_share"><div class="social-share" data-image="" data-sites="facebook,twitter,wechat,weibo,qq"></div><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/butterfly-extsrc/sharejs/dist/css/share.min.css" media="print" onload="this.media='all'"><script src="https://cdn.jsdelivr.net/npm/butterfly-extsrc/sharejs/dist/js/social-share.min.js" defer></script></div></div><nav class="pagination-post" id="pagination"><div class="prev-post pull-full"><a href="/2022/07/07/%E6%AD%A3%E5%88%99%E8%A1%A8%E8%BE%BE%E5%BC%8F/"><img class="prev-cover" src="" onerror="onerror=null;src='/img/404.jpg'" alt="cover of previous post"><div class="pagination-info"><div class="label">上一篇</div><div class="prev_info">正则表达式</div></div></a></div></nav></div><div class="aside-content" id="aside-content"><div class="card-widget card-info"><div class="is-center"><div class="avatar-img"><img src="/img/emplay.png" onerror="this.onerror=null;this.src='/img/friend_404.gif'" alt="avatar"/></div><div class="author-info__name">emplay</div><div class="author-info__description">博学之，审问之，慎思之，明辨之，笃行之</div></div><div class="card-info-data site-data is-center"><a href="/archives/"><div class="headline">文章</div><div class="length-num">2</div></a><a href="/tags/"><div class="headline">标签</div><div class="length-num">1</div></a><a href="/categories/"><div class="headline">分类</div><div class="length-num">2</div></a></div><a id="card-info-btn" href="https://blog.emplay.top/"><i class="fab fa-github"></i><span>返回主页</span></a><div class="card-info-social-icons is-center"><a class="social-icon" href="https://gitee.com/emplay/emplay" target="_blank" title="Github"><i class="fab fa-github"></i></a><a class="social-icon" href="mailto:871586557@qq.com" target="_blank" title="Email"><i class="fas fa-envelope"></i></a></div></div><div class="card-widget card-announcement"><div class="item-headline"><i class="fas fa-bullhorn fa-shake"></i><span>公告</span></div><div class="announcement_content">This is my Blog</div></div><div class="sticky_layout"><div class="card-widget" id="card-toc"><div class="item-headline"><i class="fas fa-stream"></i><span>目录</span><span class="toc-percentage"></span></div><div class="toc-content"><ol class="toc"><li class="toc-item toc-level-1"><a class="toc-link" href="#%E4%BD%BF%E7%94%A8dbt5%E8%BF%9B%E8%A1%8CTPC-E%E6%B5%8B%E8%AF%95"><span class="toc-text">使用dbt5进行TPC-E测试</span></a><ol class="toc-child"><li class="toc-item toc-level-2"><a class="toc-link" href="#%E7%BC%96%E8%AF%91%E5%AE%89%E8%A3%85R%E8%AF%AD%E8%A8%80"><span class="toc-text">编译安装R语言</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E7%BC%96%E8%AF%91%E5%AE%89%E8%A3%85Python%E6%8F%92%E4%BB%B6rpy2"><span class="toc-text">编译安装Python插件rpy2</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E7%BC%96%E8%AF%91%E5%AE%89%E8%A3%85dbt5"><span class="toc-text">编译安装dbt5</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#%E7%BC%96%E8%AF%91%E5%AE%89%E8%A3%85"><span class="toc-text">编译安装</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E6%8A%A5%E9%94%99%E5%A4%84%E7%90%86"><span class="toc-text">报错处理</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%8A%9F%E8%83%BD%E8%AF%B4%E6%98%8E"><span class="toc-text">功能说明</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E5%BC%80%E5%A7%8B%E6%B5%8B%E8%AF%95"><span class="toc-text">开始测试</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#%E8%AE%BE%E7%BD%AE%E7%8E%AF%E5%A2%83%E5%8F%98%E9%87%8F"><span class="toc-text">设置环境变量</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%88%9B%E5%BB%BA%E6%B5%8B%E8%AF%95%E6%95%B0%E6%8D%AE%E5%BA%93"><span class="toc-text">创建测试数据库</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E8%BF%90%E8%A1%8C%E6%B5%8B%E8%AF%95"><span class="toc-text">运行测试</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#TPC-E%E5%8F%8Adbt5%E7%AE%80%E5%8D%95%E4%BB%8B%E7%BB%8D"><span class="toc-text">TPC-E及dbt5简单介绍</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#%E4%BB%80%E4%B9%88%E6%98%AFTPC-E"><span class="toc-text">什么是TPC-E</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E4%B8%8ETPCC%E7%9A%84%E5%8C%BA%E5%88%AB"><span class="toc-text">与TPCC的区别</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E4%BB%80%E4%B9%88%E6%98%AFdbt5"><span class="toc-text">什么是dbt5</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#dbt5%E6%9E%B6%E6%9E%84"><span class="toc-text">dbt5架构</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#dbt5%E4%B8%AD%E7%9A%84%E8%A1%A8"><span class="toc-text">dbt5中的表</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#dbt5%E7%9A%84%E4%BC%98%E7%BC%BA%E7%82%B9"><span class="toc-text">dbt5的优缺点</span></a></li></ol></li></ol></li></ol></div></div><div class="card-widget card-recent-post"><div class="item-headline"><i class="fas fa-history"></i><span>最新文章</span></div><div class="aside-list"><div class="aside-list-item"><a class="thumbnail" href="/2022/07/20/%E4%BD%BF%E7%94%A8dbt5%E8%BF%9B%E8%A1%8CTPC-E%E6%B5%8B%E8%AF%95/" title="使用dbt5进行TPC-E测试"><img src="" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="使用dbt5进行TPC-E测试"/></a><div class="content"><a class="title" href="/2022/07/20/%E4%BD%BF%E7%94%A8dbt5%E8%BF%9B%E8%A1%8CTPC-E%E6%B5%8B%E8%AF%95/" title="使用dbt5进行TPC-E测试">使用dbt5进行TPC-E测试</a><time datetime="2022-07-20T00:00:00.000Z" title="发表于 2022-07-20 00:00:00">2022-07-20</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/2022/07/07/%E6%AD%A3%E5%88%99%E8%A1%A8%E8%BE%BE%E5%BC%8F/" title="正则表达式"><img src="" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="正则表达式"/></a><div class="content"><a class="title" href="/2022/07/07/%E6%AD%A3%E5%88%99%E8%A1%A8%E8%BE%BE%E5%BC%8F/" title="正则表达式">正则表达式</a><time datetime="2022-07-07T00:00:00.000Z" title="发表于 2022-07-07 00:00:00">2022-07-07</time></div></div></div></div></div></div></main><footer id="footer"><div id="footer-wrap"><div class="copyright">&copy;2022 By emplay</div><div class="framework-info"><span>框架 </span><a target="_blank" rel="noopener" href="https://hexo.io">Hexo</a><span class="footer-separator">|</span><span>主题 </span><a target="_blank" rel="noopener" href="https://github.com/jerryc127/hexo-theme-butterfly">Butterfly</a></div></div></footer></div><div id="rightside"><div id="rightside-config-hide"><button id="readmode" type="button" title="阅读模式"><i class="fas fa-book-open"></i></button><button id="darkmode" type="button" title="浅色和深色模式转换"><i class="fas fa-adjust"></i></button><button id="hide-aside-btn" type="button" title="单栏和双栏切换"><i class="fas fa-arrows-alt-h"></i></button></div><div id="rightside-config-show"><button id="rightside_config" type="button" title="设置"><i class="fas fa-cog fa-spin"></i></button><button class="close" id="mobile-toc-button" type="button" title="目录"><i class="fas fa-list-ul"></i></button><button id="go-up" type="button" title="回到顶部"><i class="fas fa-arrow-up"></i></button></div></div><div id="local-search"><div class="search-dialog"><nav class="search-nav"><span class="search-dialog-title">搜索</span><span id="loading-status"></span><button class="search-close-button"><i class="fas fa-times"></i></button></nav><div class="is-center" id="loading-database"><i class="fas fa-spinner fa-pulse"></i><span>  数据库加载中</span></div><div class="search-wrap"><div id="local-search-input"><div class="local-search-box"><input class="local-search-box--input" placeholder="搜索文章" type="text"/></div></div><hr/><div id="local-search-results"></div></div></div><div id="search-mask"></div></div><div><script src="/js/utils.js"></script><script src="/js/main.js"></script><script src="https://cdn.jsdelivr.net/npm/@fancyapps/ui/dist/fancybox.umd.min.js"></script><script src="https://cdn.jsdelivr.net/npm/instant.page/instantpage.min.js" type="module"></script><script src="/js/search/local-search.js"></script><script>var preloader = {
  endLoading: () => {
    document.body.style.overflow = 'auto';
    document.getElementById('loading-box').classList.add("loaded")
  },
  initLoading: () => {
    document.body.style.overflow = '';
    document.getElementById('loading-box').classList.remove("loaded")

  }
}
window.addEventListener('load',preloader.endLoading())</script><div class="js-pjax"></div><script async data-pjax src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script></div></body></html>